package org.sgr.money.manager.frame;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;

public class CashComp extends Composite {

	private Button button = null;
	private Button button1 = null;
	private Table table = null;
	private Button button2 = null;

	public CashComp(Composite parent, int style) {
		super(parent, style);
		initialize();
	}

	private void initialize() {

		button = new Button(this, SWT.NONE);
		FormData data = new FormData();
		data.top = new FormAttachment(0, 3);
		data.left = new FormAttachment(0, 10);
		data.width = 70;
		button.setLayoutData(data);
		button.setText("增加");
		button.addMouseListener(new org.eclipse.swt.events.MouseAdapter() {
			public void mouseUp(org.eclipse.swt.events.MouseEvent e) {
				System.out.println("mouseUp()"); // TODO Auto-generated Event
													// stub mouseUp()
				createCachAcct();
			}

		});

		button1 = new Button(this, SWT.NONE);
		data = new FormData();
		data.top = new FormAttachment(0, 3);
		data.left = new FormAttachment(0, 90);
		data.width = 70;
		button1.setLayoutData(data);
		button1.setText("删除");

		button2 = new Button(this, SWT.NONE);
		data = new FormData();
		data.top = new FormAttachment(0, 3);
		data.left = new FormAttachment(0, 170);
		data.width = 70;
		button2.setLayoutData(data);
		button2.setText("修改");

		table = new Table(this, SWT.BORDER | SWT.CHECK);
		table.setHeaderVisible(true);
		table.setLinesVisible(true);

		data = new FormData();
		data.top = new FormAttachment(0, 35);
		data.left = new FormAttachment(0, 0);
		data.bottom = new FormAttachment(100, 0);
		data.right = new FormAttachment(100, 0);
		table.setLayoutData(data);

		TableColumn tableColumn11 = new TableColumn(table, SWT.NONE);
		tableColumn11.setWidth(40);
		tableColumn11.setText("序号");

		TableColumn tableColumn = new TableColumn(table, SWT.NONE);
		tableColumn.setWidth(160);
		tableColumn.setText("账户名称");

		TableColumn tableColumn1 = new TableColumn(table, SWT.NONE);
		tableColumn1.setWidth(120);
		tableColumn1.setText("余额");

		TableColumn tableColumn2 = new TableColumn(table, SWT.NONE);
		tableColumn2.setWidth(200);
		tableColumn2.setText("管理方式");

		TableColumn tableColumn3 = new TableColumn(table, SWT.NONE);
		tableColumn3.setWidth(80);
		tableColumn3.setText("状态");

		setSize(new Point(500, 200));
		setLayout(new FormLayout());
	}

	private void createCachAcct() {
		// TODO Auto-generated method stub
		Shell child = new Shell(getShell(), SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
		FormLayout formlayout = new FormLayout();
		child.setLayout(formlayout);
		new CashAcctAddComp(child, getStyle());
		int cx = 320;
		int cy = 260;
		child.setSize(new Point(cx, cy));
		child.setText("增加现金账户");
		int lx = getShell().getLocation().x + getShell().getSize().x / 2 - cx / 2;
		int ly = getShell().getLocation().y + getShell().getSize().y / 2 - cy / 2;
		child.setLocation(lx, ly);
		child.open();
	}
}
